<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--引入JSTL标签--%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no,initial-scale=1.0 maximum-scale=1.0,minimum-scale=1.0">
    <title>你的零食我包了——零食盒子</title>
    <%
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
    %>
    <base href="<%=basePath%>">
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/index.css">
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_1728297_wjawl1c3q3j.css">
    <script src="static/script/jquery-1.7.2.js"></script>
    <script src="js/flexible.js"></script>
    <script type="text/javascript">
        $(function () {
            $("button#gocart").click(function () {
                var bookid = $(this).attr("bookid");
                //location.href = "cartServlet?action=addtocart&id=" + bookid;
                $.getJSON("cartServlet", "action=addtocart&id=" + bookid, function (data) {
                    $("#cartlastname").text(data.lastname);
                })

            });
            $("button#callfood").click(function () {
                var bookname = $(this).attr("bookname");
                //location.href = "cartServlet?action=call&bookname=" + bookname;
                $.getJSON("cartServlet", "action=call&bookname=" + bookname,function (msg) {
                    alert('您的补货请求我们已收到，请耐心等待');
                })
            });
        });
    </script>
</head>
<body>
<div class="nav">
    <div class="logo"><img src="images/logo.png" alt=""></div>
    <div class="address">${sessionScope.louhao}号楼${sessionScope.sushehao}宿舍</div>
    <div class="all">
        <a href="sms:15536072652">
            <i class="iconfont icon-smile"><span>联系客服</span></i>
        </a>
    </div>
</div>
<div class="main">
    <div class="left">
        <div class="box1"><a href="foodServlet?action=all">全品热卖</a></div>
        <div class="box1"><a href="foodServlet?action=ls">零食</a></div>
        <div class="box1"><a href="foodServlet?action=latiao">辣条</a></div>
        <div class="box1"><a href="foodServlet?action=pm">泡面</a></div>
        <div class="box1"><a href="foodServlet?action=yl">饮料</a></div>
        <div class="box1"><a href="foodServlet?action=phsp">膨化食品</a></div>
        <div class="ed">
            您刚刚将<span id="cartlastname" style="color: red"></span>加到了购物车中!
        </div>
    </div>
    <div class="right">
        <c:forEach items="${requestScope.foods}" var="food">
            <div class="shop1">
                <img src=${food.imgpath} alt="">
                <div class="name">${food.name}</div>
                <div class="price">￥${food.price}</div>
                <div class="anniu">
                    <button bookid="${food.id}" id="gocart" class="iconfont icon-jiarugouwuche"></button>
                    <button bookname="${food.name}" id="callfood" class="iconfont icon-buhuoqianshou"></button>
                </div>
            </div>
        </c:forEach>
    </div>
</div>
<div class="dibu">
    <div class="all">
        <a href="#">
            <i class="iconfont icon-all"><span>商 品</span></i>
        </a>
    </div>

    <div class="cart">
        <a href="pages/user/cart.jsp">
            <i class="iconfont icon-cart"><span>购物车</span></i>
        </a>
    </div>
</div>

</body>

</html>